-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run OCR on image after saving (synchronously!) (#20) #26
base: main
Are you sure you want to change the base?
Conversation
Have you benchmarked how long it takes to upload and process 3 photos? If this is <1s, I wouldn't mind. Uploads from smartphone already take longer on most phones (with high resolution images). |
I just did a quick test and it took a little less than 6 seconds to upload 3 smartphone photos. So, in the long run, i think that moving such tasks in the background would make sense. |
I agree, background seems like the way to go. |
I have changed the code so that celery is used if available. Celery requires a redis instance and a separate worker process. If the config variable CELERY_TASK_ALWAYS_EAGER is set to True in local_settings.py, then tasks will be executed in the foreground. If you want to run celery in the dev environment, use the command |
Thank you for the info! I am planning to be there as well this time, hopefully around 18:30. |
Unfortunately, I won't be able to attend. 😢 |
This is a first implementation for running OCR whenever an image is newly created or changed. One major downside of this implementation is that saving an Item where the image has been changed now takes much longer because the OCR is running on django's main thread.
A better approach would probably be to use something like Celery to run OCR tasks in the background. The latter approach would also allow us to run periodic tasks. However this would add more dependencies and background services to the project.
Just let me know whether you would prefer the solution submitted in this PR or the one i have just described :)